package com.bawei.liuzhanlin20210806.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bawei.liuzhanlin20210806.R;
import com.bawei.liuzhanlin20210806.model.bean.XlBean;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Time: 2021/8/6
 * Author:liuzhanlin
 * Description:zhuangao6
 */
public class XlAdapter extends RecyclerView.Adapter<XlAdapter.Myhandler> {
    private List<XlBean.DataDTO.ResultDTO.TrainsDTO> list;
    private Context context;

    public XlAdapter(List<XlBean.DataDTO.ResultDTO.TrainsDTO> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public Myhandler onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new Myhandler(LayoutInflater.from(context).inflate(R.layout.a, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull Myhandler holder, int position) {
        holder.sdvTu.setImageURI("http://172.17.27.50/moni/"+list.get(position).image);
        holder.mc.setText(list.get(position).title);
        holder.xl.setText(list.get(position).groupNumber+"组训练");
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class Myhandler extends RecyclerView.ViewHolder {
        @BindView(R.id.sdv_tu)
        SimpleDraweeView sdvTu;
        @BindView(R.id.mc)
        TextView mc;
        @BindView(R.id.xl)
        TextView xl;
        public Myhandler(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
